﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;


namespace ServerShared.AppData
{
    public partial class User
    {
        public void SetId(long id)
        {
            this.m_Id = id;
        }

        public User(long id, string nickName, string token, int maxLv, int coin, int diamond, bool isRobot,
            int loginDay,
            List<int> obtainedLoginBonus, List<long> friends, MiniUserInfo userInfo)
        {
            this.m_Id = id;
            this.m_Token = token;
            this.m_MaxLv = maxLv;
            this.m_Coin = coin;
            this.m_Diamond = diamond;
            this.m_IsRobot = isRobot;
            this.m_LoginedDay = loginDay;
            this.m_ObtainLoginBonus = obtainedLoginBonus;
            this.miniUserInfo = userInfo;
            this.m_Friends = friends;
        }

        public int AddDiamond(int addNum)
        {
            int diamond = this.m_Diamond + addNum;
            UpdateDiamond(diamond);

            return diamond;
        }

        public int MinusDiamond(int minusNum)
        {
            int diamond = this.m_Diamond - minusNum;
            diamond = diamond < 0 ? 0 : diamond;
            UpdateDiamond(diamond);

            return diamond;
        }

        public void UpdateStageLevel(int stage)
        {
            this.m_Level = stage;
        }

        public int AddLoginDay()
        {
            m_LoginedDay++;
            return m_LoginedDay;
        }

        public void ObtainLoginBonus(int day)
        {
            this.m_ObtainLoginBonus.Add(day);
        }

        public void UpdateBaseInfo(MiniUserInfo userBaseInfoData)
        {
            miniUserInfo = userBaseInfoData;
        }
    }

}